package com.cxj.musicplayer.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileUtil {

    public static Bitmap get_pic_from_local(Context context, String song_id){
        String path = context.getApplicationContext().getFilesDir().getAbsolutePath() + "/song_pic/" + song_id + ".jpg";
        File file = new File(path);
        if(file.exists()){
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(path);
                return BitmapFactory.decodeStream(fis);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }finally {
                try {
                    if(null != fis) {
                        fis.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }

    public static void save_pic_to_local(Bitmap pic){

    }
}
